<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>个人信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__PUBLIC__/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">个人信息</div>
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="" lay-filter="component-form-group" id="myform">

                <div class="layui-form-item">
                    <label class="layui-form-label">登录密码</label>
                    <div class="layui-input-block">
                        <input type="text" name="us_pwd" placeholder="不填写则为原密码" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">最后登录IP</label>
                    <div class="layui-input-inline">
                        <input type="text" name="us_ip" autocomplete="off" value="{$find.us_ip}" readonly class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>推广二维码
                    </label>
                    <div class="layui-input-inline">
                        <img src="__PUBLIC__/{$find.us_img_code}" style="width: 100px;"/>
                    </div>
                    <div class="layui-form-mid layui-word-aux"><button class="layui-btn layui-btn-primary" onclick="code('{$find.us_uid}')">刷新</button></div>
                </div>
                <input type="hidden" name="us_uid" value="{$find.us_uid}">
                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            <button class="layui-btn" lay-submit="" lay-filter="component-form-demo1" onclick="sub()">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>


<script src="__PUBLIC__/layuiadmin/layui/layui.js"></script>
<script>
    layui.use(['form', 'layer'], function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
    });
    function sub() {
        $.ajax({
            type:'post',
            url:'{:url("User/userEdit")}',
            data:$("#myform").serialize(),
            success: function (data) {
                if(data.code>0){
                    layer.msg(data.msg,{icon:1,time:1500});
                    setTimeout(function(){parent.location.reload()},1500);
                }else{
                    layer.msg(data.msg,{icon:5,time:1500});
                }
            },
            error: function (data) {
                console.log(data.msg);
            },
        });
    }
    function code(uid){
        $.ajax({
            type: 'POST',
            url: '{:url("User/code")}',
            data: {uid:uid},
            success: function (data) {
                if(data.code>0){
                    layer.msg(data.msg, {icon: 6, time: 1500});
                    setTimeout(function () {
                        xadmin.close();//关闭当前窗口
                        xadmin.father_reload();//刷新
                    },1500)
                }else{
                    layer.msg(data.msg, {icon: 5, time: 1500});
                }
            },
            error: function (data) {
                console.log(data.msg);
            },
        });
    }

</script>
</body>
</html>
